package DBFunction;
import org.apache.log4j.Logger;
import DTO.Position;
import java.sql.ResultSet;
import java.sql.SQLException;

public class PositionManager {
	public static Logger logger = Logger.getLogger("BuddyTrackingServer");
	public static Position getPositionById(String inputId)throws SQLException{
		Position resultPosition = new Position();
		String sql ="SELECT * FROM buddytracking.position WHERE UserId='"+inputId+"'";
		ResultSet result = DB.connectDB.ExecuteQuery(sql);
		while(result.next()){
			resultPosition.setUserId(result.getString("UserId"));
			resultPosition.setLong(result.getString("Longitude"));
			resultPosition.setLat(result.getString("Latitude"));
		}
		logger.info("PositionManager.getPositionById: "+resultPosition.getUserId()+" Long "+resultPosition.getLong()+" Lat "+resultPosition.getLat()+" ");
		return resultPosition;
	}
}
